package com.YxyBackMange.Service.web.impl;

import com.YxyBackMange.Entity.Ware.WareAppointment;
import com.YxyBackMange.Mapper.web.WebAppointmentMapper;
import com.YxyBackMange.Service.web.WebAppointmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Calendar;
import java.util.Date;

/**
 * @outhor 路♥克
 * 2017-12-15 22:28
 */
@Service
public class WebAppointmentServiceImpl implements WebAppointmentService {

    @Autowired
    private WebAppointmentMapper webAppointmentMapper;
    @Override
    public WareAppointment insertService(WareAppointment o) {
        Date date = new Date();
        o.setOpterateTime(date);
        o.setCreateTime(date);
        o.setStateId(4);
        o.setAppointmentTypeId(2);
        Calendar now =Calendar.getInstance();
        now.setTime(date);
        //获取5天以后的日期
        now.set(Calendar.DATE,now.get(Calendar.DATE)+5);
        o.setAppointmentTime(now.getTime());
        if (webAppointmentMapper.insertSelective(o)>0) {
            return o;
        }
        return null;
    }

    @Override
    public WareAppointment updateService(WareAppointment o) {
        return null;
    }

    @Override
    public WareAppointment insert(WareAppointment o) {
        return null;
    }

    @Override
    public WareAppointment update(WareAppointment o) {
        return null;
    }

    @Override
    public WareAppointment delete(WareAppointment o) {
        if (webAppointmentMapper.delete(o)>0) {
            return o;
        }
        return null;
    }
}
